
var is_tutor = 0;
var index = 0;

$(function(){

    $('.login').on('click',function(){


        if(index == 0){
            mesLay('房间号有误,请重新输入！');
            return false;
        }
        else {
            var houseNumber = $('#houseNumber').val();

            var url = 'http://120.79.245.60:8080/eooker/a/sys/userAPI/verification/' + houseNumber;
            // 816623';

            $.ajax({
                url: url,
                type: 'Get',
                dataType: 'JSON',
                crossDomain: true,
                success: function (data) {
                    if(data.message == 1)
                    {
                        window.localStorage.setItem('CourseNumber', houseNumber);
                        self.location = 'choose_seat.html';
                    }
                    else {
                        mesLay('房间号不存在请重新输入');
                        $('#houseNumber').val('');
                        $('#houseNumber').focus();
                        return false;
                    }

                },
                fail: function (data) {
                    alert("进入房间失败，请联系管理员");
                }
            });
        }

    });

    function houseNumber(){

        var reg = /^\d{6}$/;
        var nameVal = $('.u_name').val();
        if(reg.test(nameVal)){
            index = 1;
        }else{
            mesLay('房间号有误！');
            index = 0;
            return false;
        }

    }

    function mesLay(content){
        layer.open({
            content: content
            ,skin: 'msg'
            ,time: 2
        });
    }


    $('#houseNumber').blur(function(){
        houseNumber();
    });
})